home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Technical Documentation / PCI Information / PCI Developer’s Kit (disk) / Native Drivers / NuDriver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-27  |  3.9 KB  |  201 lines  |  [TEXT/MPCC]

  1. #include "Devices.h"
  2. #include "Files.h"
  3.  
  4. #include "NuDrivers.h"
  5. #include "NuDriverSupportLib.h"
  6.  
  7. // Driver Description Symbol
  8. DriverDescription TheDriverDescription =
  9. {
  10.     theDescriptionSignature,
  11.     0,
  12.     'DISP',
  13.     'TEST',
  14.     'TEST',
  15.     'APPL',
  16.     0,
  17.     false,
  18.     false,
  19.     3,
  20.     'N',
  21.     'E',
  22.     'W'
  23. };
  24.  
  25. DCtlPtr    MyDce;
  26.  
  27. //////////////////////////////////////////////////////////////
  28. // Open, Close, KillIO, Initialize, and Finalize are always //
  29. //                    ImmediateIORequestKind                    //
  30. //////////////////////////////////////////////////////////////
  31.  
  32. ////////////////////////////////////////////////////
  33. //
  34. // DoOpenCmd
  35. //
  36. OSErr DoOpenCmd        (    ParmBlkPtr        thePb)
  37. {
  38.     return noErr;
  39. }
  40.                         
  41.  
  42. ////////////////////////////////////////////////////
  43. //
  44. // DoCloseCmd
  45. //
  46. OSErr DoCloseCmd    (    ParmBlkPtr        thePb)
  47. {
  48.     return noErr;
  49. }
  50.                         
  51.  
  52. ////////////////////////////////////////////////////
  53. //
  54. // DoKillIOCmd
  55. //
  56. OSErr DoKillIOCmd    (    ParmBlkPtr        thePb)
  57. {
  58.     return noErr;
  59. }
  60.                         
  61. ////////////////////////////////////////////////////
  62. //
  63. // DoInitializeCmd
  64. //
  65. OSErr DoInitializeCmd    (    DCtlPtr            theDce)
  66. {
  67.     // Remember our DCE.
  68.     MyDce    =    theDce;
  69.     
  70.     return noErr;
  71. }
  72.                         
  73. ////////////////////////////////////////////////////
  74. //
  75. // DoFinalizeCmd
  76. //
  77. OSErr DoFinalizeCmd        (    DCtlPtr            theDce)
  78. {
  79.     return noErr;
  80. }
  81.                         
  82. //////////////////////////////////////////////////////////////
  83. //            Read, Write, Status, and Control may be            //
  84. //                    ImmediateIORequestKind                    //
  85. //////////////////////////////////////////////////////////////
  86.  
  87. ////////////////////////////////////////////////////
  88. //
  89. // DoReadCmd
  90. //
  91. OSErr DoReadCmd            (    ParmBlkPtr        thePb)
  92. {
  93.     return noErr;
  94. }
  95.                         
  96.  
  97. ////////////////////////////////////////////////////
  98. //
  99. // DoWriteCmd
  100. //
  101. OSErr DoWriteCmd        (    ParmBlkPtr        thePb)
  102. {
  103.     return noErr;
  104. }
  105.                         
  106.  
  107. ////////////////////////////////////////////////////
  108. //
  109. // DoControlCmd
  110. //
  111. OSErr DoControlCmd        (    ParmBlkPtr        thePb)
  112. {
  113.     return noErr;
  114. }
  115.                         
  116.  
  117. ////////////////////////////////////////////////////
  118. //
  119. // DoStatusCmd
  120. //
  121. OSErr DoStatusCmd        (    ParmBlkPtr        thePb)
  122. {
  123.     return noErr;
  124. }
  125.                         
  126.  
  127. //////////////////////////////////////////////////////////////
  128. //
  129. // DoDriverIO        ( The Driver Entry Point )
  130. //
  131. //////////////////////////////////////////////////////////////
  132. OSErr DoDriverIO    (    IOCommandID                theID,
  133.                         IOCommandContents        theContents,
  134.                         IOCommandCode            theCode,
  135.                         IOCommandKind            theKind )
  136. {
  137.     DCtlPtr        theDce            = theContents.theInitialInfo->theDce;
  138.     ParmBlkPtr    thePb            = theContents.thePb;
  139.     OSErr        ImmediateResult = noErr;
  140.     
  141.     switch ( theCode )
  142.     {
  143.         // The following commands are always immediate.
  144.         
  145.         // Initalize and Finalize take a DCE as the lone parameter
  146.         case    InitializeCmd:
  147.                     return DoInitializeCmd        ( theDce );
  148.         case    FinalizeCmd:
  149.                     return DoFinalizeCmd        ( theDce );
  150.         
  151.         // Open, Close, and KillIO take a PB as the lone parameter
  152.         case    OpenCmd:
  153.                     return DoOpenCmd            ( thePb );
  154.         case    CloseCmd:
  155.                     return DoCloseCmd            ( thePb );
  156.         case    KillIOCmd:
  157.                     return DoKillIOCmd            ( thePb );
  158.  
  159.         // The remaining commands may be immediate.
  160.         case    ReadCmd:
  161.                     ImmediateResult = DoReadCmd        ( thePb );
  162.                     break;
  163.         case    WriteCmd:
  164.                     ImmediateResult = DoWriteCmd    ( thePb );
  165.                     break;
  166.         case    ControlCmd:
  167.                     ImmediateResult = DoControlCmd    ( thePb );
  168.                     break;
  169.         case    StatusCmd:
  170.                     ImmediateResult = DoStatusCmd    ( thePb );
  171.                     break;
  172.     }
  173.     
  174.     // If an immediate command make sure to return a valid result
  175.     if ( (theKind & ImmediateIOCommandKind) != 0 )
  176.         return ImmediateResult;
  177.         
  178.     // else return noErr via the new IODone
  179.     return IOCommandIsComplete ( theID, noErr, true );
  180. }
  181.  
  182. //////////////////////////////////////////////////////////////
  183. //
  184. // Called by CFM upon initialization of the Driver
  185. //
  186. //////////////////////////////////////////////////////////////
  187. CFMInitialize ()
  188. {
  189.     return noErr;
  190. }
  191.  
  192. //////////////////////////////////////////////////////////////
  193. //
  194. // Called by CFM upon termination of the Driver
  195. //
  196. //////////////////////////////////////////////////////////////
  197. CFMTerminate ()
  198. {
  199.     return noErr;
  200. }
  201.